<?php

namespace IDock\Insurance\CHAC\Response;

use IDock\Http\Response;
use IDock\Printer\PremiumUnderwritingPrinter;
use IDock\Printer\ValidateCarCodePrinter;

class ValidateCarResponse extends AllCHACResponse
{

    /*** @var ValidateCarCodePrinter $printer */
    public $printer = ValidateCarCodePrinter::class;

    public $urlDecode = true;

    public function printerInit(): Response
    {

        $header = $this->get('responseHead');

        if ($header['responseCode'] != '0000') {
            $this->setError($header['errorMessage'] ?? '');
            return $this;
        }

        $body = $this->get('responseBody');

        $this->printer->code = $body['carVerifyCodeList'][0]['verifyCode'] ?? '';

        return $this;
    }
}
